package ControllerSrevlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import MYJDBC.jdbc;
import User_index.Video_Play;
import User_index.Video_dao;


/**
 * Servlet implementation class BlueVideoPlay
 */
@WebServlet("/BlueVideoPlay")
public class BlueVideoPlay extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BlueVideoPlay() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		String VideoString = request.getParameter("VideoID");
		int VideoID = Integer.parseInt(VideoString);
		
		Video_Play vios = new Video_Play();
		Video_dao vio = new Video_dao();
		jdbc jc = new jdbc();
		request.setAttribute("SqlUser",jc.getSqlUser());
		request.setAttribute("SqlPass",jc.getSqlPass());
		request.setAttribute("SqlName", jc.getSqlName());
		try {
			vio = vios.VideoSelect(VideoID);
			request.setAttribute("Video",vio);
			request.getRequestDispatcher("VideoPlay.jsp").forward(request, response);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
